﻿using System;
using System.Collections.Generic;
using System.Linq;
using Fuse8.ContentManagementFramework.Domain.Commands;
using Fuse8.ContentManagementFramework.Domain.Commands.CommandParameters;
using Fuse8.DomainFramework.BusinessService;

using Fuse8.ContentManagementFramework.Domain;
using Fuse8.DomainFramework.Common.Locator;

namespace Fuse8.ContentManagementFramework.BizFacade.Services
{
    public class CmsEntityMetaFieldService : BaseBusinessService<CmsEntityMetaField, int>
    {
        public CmsEntityMetaField FindByName(string metaFieldName, string metaFieldType)
        {
            var command = DependencyServiceLocator.Current.GetInstance<CmsMetaFieldGetByNameAndEntityTypeCommand>();
            var parameter = new CmsMetaFieldGetByNameCommandParameter()
                                {
                                    MetaFieldName = metaFieldName,
                                    MetaFieldType = metaFieldType
                                };
            command.ConfigureCommand(parameter);

            var cmsEntityMetaField = FindOne(command);

            return cmsEntityMetaField;
        }        
    }
}
